<?php
/**
 * Created by PhpStorm.
 * User: River
 * Email: river0428@gmail.com
 * Date: 2018/10/30
 * Time: 下午1:50
 */

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class RechargeOrderDetail extends Model
{
    protected $table = 'recharge_order_detail';

    public $guarded = [];

    public $appends = ['recharge_mode_name'];

    public function order()
    {
        return $this->belongsTo(RechargeOrder::class);
    }

    public function oilCard()
    {
        return $this->belongsTo(OilCard::class);
    }

    public function getRechargeModeNameAttribute()
    {
        switch($this->recharge_mode){
            case 1:
                return '自动';
            case 2:
                return '手动';
            case 3:
                return '混合';
            default:
                return '未定义';
        }
    }
}